package com.itheima;

import com.itheima.pojo.Question;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @Author: liangWeiQUQ
 * @Description: 创建索引和类型映射
 * @DateTime: 2021/3/28 12:18
 **/
@SpringBootTest
@RunWith(SpringRunner.class)
public class testCreateIndex {
    //spring data es模板工具
    @Autowired
    private ElasticsearchTemplate template;
    @Test
    public void testCreateIndex() {
        boolean createIndex = template.createIndex(Question.class);
        System.out.println("创建索引库是否成功 ： " + createIndex);
        boolean putMapping = template.putMapping(Question.class);
        System.out.println("创建映射是否成功 ： " + putMapping);
    }
}
